<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #kk{
        top: 20px;
        left: 200px;
        position: fixed;
    }
  
</style>
<body>
    <button>开启页面点击</button>
    <button id="kk">查看滚动距离</button>
    <button>展现浮动层</button>
    <div style="display: none;">我是浮动层</div>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
    <p>111</p>
</body>
<script>
    window.onload = function(){
        let aa = document.getElementsByTagName('button');
        aa[0].onclick = function(){
            alert('当前可视宽' + document.documentElement.clientWidth)
            alert('当前可视宽高' +document.documentElement.clientHeight)
            // alert('当前可视区宽度：'+document.documentElement.clientWidth+'，当前可视区高度：'+document.documentElement.clientHeight);
        }
        aa[1].onclick = function(){
            let gg = document.documentElement.scrollTop;
            console.log(gg)
        }
        aa[2].onclick = function(){
            let divc = document.getElementsByTagName('div')[0]
            console.log(divc.style.display)
            if (divc.style.display == 'none') {
                divc.style.display = 'block';
            } else {
                divc.style.display = 'none';
            }
            
        }
    }

</script>
</html>